/**
 * Created with IntelliJ IDEA.
 * User: 12629
 * Date: 2022/2/23
 * Time: 12:13
 * Description:
 */
class Animal {
    public String name;
    public int age;

    private int count;
//    public Animal() {
//    }

    /* public Animal() {
        System.out.println("Animal_init(不带参数的构造方法)");
    }*/
    static {
        System.out.println("Animal的静态代码块！");
    }

    {
        System.out.println("Animal的实例代码块！");
    }

    public Animal(String name,int age) {
        this.name = name;
        this.age = age;
        System.out.println("Animal的带有2个参数的构造方法！");
    }


    public void sleep() {
        System.out.println(this.name+"在吃饭！");
    }
    public void bark() {
        System.out.println(this.name+"在叫！");
    }
}

class Dog extends Animal{
//    public Dog() {
//       super();
//    }
    static {
        System.out.println("Dog的静态代码块！");
    }

    {
        System.out.println("Dog的实例代码块！");
    }
    public Dog() {
        super("haha",89);
        System.out.println("Dog的不带参数的构造方法！");
    }

    public void swim() {
        System.out.println(this.name+"正在狗刨！"+"年龄："+this.age);
    }
}

class Bird extends Animal{
    public String wing;//翅膀
//    public Bird() {
//        super();
//    }
    static {
        System.out.println("Bird的静态代码块！");
    }

    {
        System.out.println("Bird的实例代码块！");
    }
    public Bird(String name, int age) {
        super(name, age);
        System.out.println("Bird的带有2个参数的构造方法！");
    }

    public void fly() {
        System.out.println(this.name+"正在飞！年龄："+this.age);
    }
}

public class TestDemo {

    public static void main(String[] args) {
        Dog dog1 = new Dog();
        System.out.println("============");
        Dog dog2 = new Dog();
    }

    public static void main2(String[] args) {
        Dog dog = new Dog();
        dog.swim();
        System.out.println("==============");
        Bird bird = new Bird("十三月",67);
        bird.fly();
    }

    public static void main1(String[] args) {
        Dog dog = new Dog();
        dog.name = "元宝！";
        dog.bark();
        dog.swim();
        System.out.println("======");
        Bird bird = new Bird("十三月",67);
        //bird.name = "十三月";
        bird.bark();
        bird.fly();
    }

}
